<template>
  <a-card :bordered="false">
    <div class="table-operator">
      <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'onlyofficeAddForm','新增')">添加</a-button>
    </div>

    <LTable
      ref="onlyofficeList"
      size="middle"
      rowKey="keyId"
      :formAttributes="formAttributes"
      :columns="columns"
      axiosUrl="/onlyofficeController/page"
      :showPagination="true"
      :showQueryForm="true"
    >
      <span slot="action" slot-scope="text, record">
        <a @click="handleEdit(record,'onlyofficeEditForm','在线编辑')">在线编辑</a>
          <a-divider type="vertical" />
        <a @click="handleEdit(record,'onlyofficeViewForm','详情')">在线查看</a>
      </span>

    </LTable>
    <onlyofficeEditForm ref="onlyofficeEditForm" @close="refresh('onlyofficeList')" @ok="refresh('onlyofficeList')"></onlyofficeEditForm>
    <onlyofficeViewForm ref="onlyofficeViewForm" @close="refresh('onlyofficeList')" @ok="refresh('onlyofficeList')"></onlyofficeViewForm>
     <onlyofficeAddForm ref="onlyofficeAddForm" @close="refresh('onlyofficeList')" @ok="refresh('onlyofficeList')"></onlyofficeAddForm>
  </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import request from '@/utils/request'
import onlyofficeEditForm from './onlyofficeEditForm'
import onlyofficeViewForm from './onlyofficeViewForm'
import onlyofficeAddForm from './onlyofficeAddForm'
import { SysMixin } from '@/mixins/SysMixin'
import LExcelUpload from '@/components/lt/LExcelUpload'
import LExcelDownload from '@/components/lt/LExcelDownload'
import defaultSettings from '@/config/defaultSettings'
export default {
    name: 'onlyofficeList',
    components: {
       LTable, onlyofficeEditForm,onlyofficeViewForm, onlyofficeAddForm
    },
    mixins: [SysMixin],
    data () {
        return {
            initDictCodes: defaultSettings.数据字典.组织下拉树,
            defaultSettings,
            formAttributes: [
                { field: 'fileName', label: '文件名称', component: 'input', condition: 'like' },
                { field: 'fileId', label: '文件编号', component: 'input', condition: 'like' },
                
            ],

            columns: [
                {
                    title: '序号',
                    dataIndex: '',
                    key: 'rowIndex',
                    width: 60,
                    align: 'center',
                    customRender: function (t, r, index) {
                      return parseInt(index) + 1
                    }
                },
                 {
                    title: '文件编号',
                    dataIndex: 'fileId',
                },

                {
                    title: '文件名称',
                    dataIndex: 'fileName'
                },
                {
                    title: '文件类型',
                    dataIndex: 'fileType',
                      customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.文档类型,text)
                        }
                    }
                },
                {
                    title: '创建时间',
                    dataIndex: 'createTime'

                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '220px',
                    scopedSlots: { customRender: 'action' }
                }
            ]

        }
    },
    created () {

    },
    methods: {
        handlefreeze (params) {
            var that = this
            request.get('/SysEmpController/freeze', { params: params }).then((res) => {
                if (res.success) {
                    that.$message.success(res.message)
                    that.refresh('empListTable')
                } else {
                    that.$message.warning(res.message)
                }
            })
        },
        handleUnfreeze (params) {
            var that = this
            request.get('/SysEmpController/unfreeze', { params: params }).then((res) => {
                if (res.success) {
                    that.$message.success(res.message)
                    that.refresh('empListTable')
                } else {
                    that.$message.warning(res.message)
                }
            })
        },
        handleResetPwd (params) {
            var that = this
            request.get('/SysEmpController/resetPwd', { params: params }).then((res) => {
                if (res.success) {
                    that.$message.success(res.message)
                    that.refresh('empListTable')
                } else {
                    that.$message.warning(res.message)
                }
            })
        },
        excelUpload () {
            this.$refs['LExcelUpload'].show()
        },
        excelDownload () {
            this.$refs['LExcelDownload'].show()
        }
    }
}
</script>
